{include file="public/header"}
<style>
	.sectionY_p{
		position: fixed;
		height: 46px;
		top: 0px;
		width: 100%;
		z-index: 99;
		background: none;
	}
	.sectionY_p .a1{
		position: absolute;
		left: 10px;
		top: 15px;
		width: 1rem;
	}
	.sectionY_p .p1{
		text-align: center;
		height: 46px;
		line-height: 46px;
		font-size: 18px;
		font-weight: 500;
		color: #fff;
	}
	.she_body1{
		background: #1b1c30;
	}
	.tian_y_section1 .f1{
		margin: 15px 0px;
		border-bottom: 1px solid #5b5c70;
	}
	.tian_y_section1 .f1 .list_a{
		padding: 10px 0px;
	}
	.tian_y_section1 .f1 .list_b{
		padding: 5px 0px;
		border: none;
	}
	.tian_y_section1 .f1 .list_a li{
		float: left;
		width: 33.3%;
		text-align: center;
	}
	.tian_y_section1 .f1 .list_a li:first-child{
		text-align: left;
	}
	.tian_y_section1 .f1 .list_a li:last-child{
		text-align: right;
	}
	.tian_y_section1 .f1 .list_a li a{
		display: inline-block;
		padding: 5px 10px;
		background: #8f9299;
		color: #fff;
	}
	.tian_y_section1 .f1 .list_a li.select a{
		background: #fe0002;
	}
	.tian_y_section1 .f1 .p1{
		color: #fff;
		opacity: 0.7;
	}
	.tian_y_section1 .f1 .list_b input{
		width: 100%;
		height: 30px;
		font-size: 1rem;
		background: none;
		background: #292f71 !important;
		border: none;
		color: #fff;
	}
	.tian_y_section1 .f1 .list_b img{
		width: 130px;
		height: 130px;
	}
	.tian_y_section1 .f1 .list_b {
		position: relative;
	}
	.tian_y_section1 .f1 .list_b  .st{
		position: absolute;
		right: 10px;
		top: 5px;
		padding: 5px 10px;
		border-radius: 5px;
		background: #e13716;
		color: #fff;
		font-size: 0.9rem;
	}
	.tian_y_section1 .f2{
		margin: 15px 0px;
	}
	.tian_y_section1 .f2 input{
		width: 100%;
		height: 40px;
		background-color: #268bc8;
		border: 1px solid #29f5ff;
		color: #fff;
		border-radius: 5px;
		font-size: 1rem;
	}
	/*.tian_y_section1 .hb{*/
	/*	display: none;*/
	/*}*/
	#banktypename{
		background: none;
		border: none;
		font-size: 1rem;
		color: #aaa;
		width: 100%;
	}
	.HB{
		background: url("__PUBLIC__/home/images/v10_a19.png");
		background-size: 100% 100%;
		padding: 10px;
	}

</style>
<body class="">
<div class="bg_fixed_v10_1"></div>
<div class="sectionY sectionY_tttt" >
	<a href="{:url('Paytype/new_add')}">
		<img src="__PUBLIC__/home/images/v10_a9.png" alt="" class="a1">
	</a>
	<p class="p1">
		<span class="ppp_title">收款方式</span>
	</p>
</div>
<div class="kong1"></div>

<div class="tian_y_section1" style="margin-top: 20px">
	<div class="container">
<!--		<div class="f1" style="border-bottom: none;">-->
<!--			<p class="p1">收款方式</p>-->
<!--			<div class="sm_l">-->
<!--				<select name="" id="">-->
<!--					<option  value="0" selected="selected">支付宝</option>-->
<!--					<option  value="1">微信</option>-->
<!--					<option  value="2">银行卡</option>-->
<!--				</select>-->
<!--			</div>-->
<!--		</div>-->
		<div class="HB">
<!--			支付宝设置-->
			{if $pay_type==2}
			<div class="hb">
				<form action="">
					<div class="f1">
						<p class="p1">支付宝账号</p>
						<div class="list_b clearfix">
							<input type="text" placeholder="支付宝账号" autocomplete="off" name='alipay' value="{$userinfo.email}">
						</div>
					</div>
					<div class="f1">
						<p class="p1">收款人姓名</p>
						<div class="list_b clearfix">
							<input type="text" placeholder="支付宝用户名/姓名" autocomplete="off" name='username' value="{$userinfo.emailname}">
						</div>
					</div>
					<div class="f1">
						<p class="p1">收款二维码</p>
						<div class="list_b clearfix">
							<input type="file" id="file1" data-id="1" onchange="imgChange(this);" style="height: 0px;width: 0px;" />
							<div class="dhh">
								<img id="imghead1" src="{$userinfo.emailcode|default='__PUBLIC__/home/images/b1.png'}" alt="" {if $status.ali eq 0} class="img_btn" {/if} data-id="1">
							</div>
						</div>
					</div>
					
					{if $status.ali eq 0}
					<div class="f1">
						<p class="p1">交易密码</p>
						<div class="list_b clearfix">
							<input type="password" name='pwd' class="input1" placeholder="交易密码" autocomplete="off">
						</div>
					</div>
					
					<div class="f2">
						<input type="hidden" id="upload_geturl1" value="{$userinfo.emailcode}">
						<input type="button" onclick="check_repwd_ali()" value="确定">
					</div>
					{/if}
				</form>
			</div>
			{/if}
			{if $pay_type==1}
			<div class="hb">
				<form action="">

					<div class="f1">
						<p class="p1">微信号</p>
						<div class="list_b clearfix">
							<input type="text" placeholder="请输入微信号" autocomplete="off" name='alipay2' value="{$userinfo.selfqq}">
						</div>
					</div>
					<div class="f1">
						<p class="p1">收款人姓名</p>
						<div class="list_b clearfix">
							<input type="text" placeholder="微信用户名/姓名" autocomplete="off" name='username2' value="{$userinfo.selfqqname}">
						</div>
					</div>
					<div class="f1">
						<p class="p1">收款二维码</p>
						<div class="list_b clearfix">
							<input type="file" id="file2" data-id="2" onchange="imgChange(this);" style="height: 0px;width: 0px;" />
							<div class="dhh">
								<img id="imghead2" src="{$userinfo.selfqqcode|default='__PUBLIC__/home/images/b1.png'}" alt="" {if $status.wechat eq 0} class="img_btn" {/if} data-id='2'>
							</div>
						</div>
					</div>

					{if $status.wechat eq 0}
					<div class="f1">
						<p class="p1">交易密码</p>
						<div class="list_b clearfix">
							<input type="password" placeholder="交易密码" autocomplete="off" name='pwd2'>
						</div>
					</div>
					
					<div class="f2">
						<input type="hidden" id="upload_geturl2" value="{$userinfo.selfqqcode}">
						<input type="button"  onclick="check_repwd_wechat()" value="确定">
					</div>
					{/if}
				</form>
			</div>
			{/if}
			{if $pay_type==3}
			<div class="hb">
				<form action="">

					<div class="f1">
						<p class="p1">卡片所在银行</p>
						<div class="list_b clearfix">
							<select name="banktypename" id="banktypename">
								<option value="">请选择</option>
								{volist name='catelist' id='cv'}
								<option value='{$cv.bank_name}' {if condition="$cv['bank_name'] eq $userinfo['banktypename']"} selected='selected' {/if} >{$cv.bank_name}</option>
								{/volist}
							</select>
						</div>
						<!--<img src="__PUBLIC__/home/images/a23_1.png" alt="" class="im_y">-->
					</div>
					<div class="f1">
						<p class="p1">卡片所在支行</p>
						<div class="list_b clearfix">
							<input type="text" name='bankname' placeholder="开户支行" value="{$userinfo.bankname}" >
						</div>
					</div>
					<div class="f1">
						<p class="p1">银行卡账号</p>
						<div class="list_b clearfix">
							<input type="text" name='bankcard' placeholder="银行卡号" value="{$userinfo.bankcard}">
						</div>
					</div>
					<div class="f1">
						<p class="p1">收款人</p>
						<div class="list_b clearfix">
							<input type="text" name='realname' value="{$userinfo.realname}" placeholder="请输入收款人姓名">
						</div>
					</div>


					{if $status.bank eq 0}
					<div class="f1">
						<p class="p1">交易密码</p>
						<div class="list_b clearfix">
							<input type="password"name='pwd3' placeholder="交易密码" autocomplete="off">
						</div>
					</div>
					
					<div class="f2">
						<input type="button" onclick="check_repwd_bank()" value="确定">
					</div>
					{/if}
				</form>
			</div>
			{/if}
		</div>
	</div>
</div>


<div class="big_img">
	<img src="__PUBLIC__/home/images/a5.jpg" alt="">
</div>

</body>


<script>
	$(function(){
		$("#imghead1").click(function(){
            var altval = $(this).attr('src');
            $(".big_img img").attr('src',altval);
            var dd = $(".big_img").height();
			$(".big_img").show(200);
            $(".big_img img").css("paddingTop",(dd-$(".big_img img").height())/3.5);
		})
		$("#imghead2").click(function(){
            var altval = $(this).attr('src');
            $(".big_img img").attr('src',altval);
            var dd = $(".big_img").height();
			$(".big_img").show(200);
            $(".big_img img").css("paddingTop",(dd-$(".big_img img").height())/3.5);
		})
		$(".big_img").click(function(){
			$(".big_img").hide(200);
		})
	})
</script>


<script>
	var is_app=0;
	try {
		is_app = android.getType();
	}catch (e) {
	}
	var site = 0;
	$(function(){
		$(".img_btn").click(function(){
			site = $(this).data("id");
			console.log(site);
			if(is_app==1){
				android.uploadImage(location.origin+"/home/Upload/appupimg.html");
			}else{
				$(this).parent().siblings("input").click();
			}
		})
		$(".sm_l select").change(function () {
			var dd = $(this).children('option:selected').val();
			$(".hb").eq(dd).show().siblings().hide()
		})

	})
</script>
<script type="text/javascript">
	//安卓回调
	function setImage(img_url) {
		$("#imghead"+site).attr('src',img_url); // 修改img标签src属性值
		$("#upload_geturl"+site).val(img_url);
	}
	function imgChange(obj) {
		var docObj=$(obj).get(0);
		if (docObj.files && docObj.files[0]) {
			if(!/image\/\w+/.test(docObj.files[0].type)){
				//图片文件的type值为image/png或image/jpg
				layer.msg("文件必须为图片！");
				return false;
			}
			var formData = new FormData();
			formData.append("files",docObj.files[0]);
			$.ajax({
				url: "{:url('Upload/upimg')}",
				type: "POST",
				data: formData,
				/**
				 *必须false才会自动加上正确的Content-Type
				 */
				contentType: false,
				/**
				 * 必须false才会避开jQuery对 formdata 的默认处理
				 * XMLHttpRequest会对 formdata 进行正确的处理
				 */
				processData: false,
				success: function (rs) {
					rs = JSON.parse(rs);
					if(rs.status==0){
						setImage(rs.data)
					}else{
						layer.alert(rs.info,{shade:0.2});return false;
					}
				},
				error: function () {
					layer.msg('系统错误，请稍后重试');
				}
			});
		} else {
			layer.msg('请上传图片');
		}
		return true;
	}
	/*开始检测交易密码和各个选项是否填写 支付宝交易填写 */
	function check_repwd_ali(){
		var name= $('input[name=username]').val();
		var user= $('input[name=alipay]').val();
		var repwd  = $('input[name=pwd]').val();
		if(name==''){
			layer.alert('请填写支付宝昵称或姓名！');return false;
		}
		if(user==''){
			layer.alert('请填写支付宝账号！');return false;
		}

		if(repwd==''){
			layer.alert('请填写交易密码！');return false;
		}
		/*ajax检测交易密码*/
		$.ajax({
			type: 'POST',
			url: "{:url('Paytype/check_repwd')}",
			dataType: "html",
			data: "code="+repwd,
			success:function(responsestr){
				if(responsestr==1){
					var img_url=$('#upload_geturl1').val();
					if(img_url==''){
						layer.alert('请上传支付宝收款码！');return false;
					}
					$.ajax({
						type: 'POST',
						url: "{:url('Paytype/doalipay')}",
						dataType: "json",
						data: {username:name,alipay:user,upload_geturl:img_url},
						success:function(re){
							var obj=re;
							if(obj.s==1){
								layer.msg(obj.msg,{shade:0.6,time:1000,end:function(){
										window.location.href=window.location.href;
									}});
							}else{
								layer.alert(obj.msg,{shade:0.2});return false;
							}
						},
						error:function(){
							layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
						}
					});
				}else{
					layer.alert(responsestr,{shade:0.2});
				}
			},
			error:function(){
				layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
			}
		});
	}

	/*开始检测交易密码和各个选项是否填写 微信交易*/
	function check_repwd_wechat(){
		var name= $('input[name=username2]').val();
		var user= $('input[name=alipay2]').val();

		var repwd  = $('input[name=pwd2]').val();
		if(name==''){
			layer.alert('请填写微信昵称或姓名！');return false;
		}
		if(user==''){
			layer.alert('请填写微信号！');return false;
		}

		if(repwd==''){
			layer.alert('请填写交易密码！');return false;
		}
		/*ajax检测交易密码*/
		$.ajax({
			type: 'POST',
			url: "{:url('Paytype/check_repwd')}",
			dataType: "html",
			data: "code="+repwd,
			success:function(responsestr){
				if(responsestr==1){
					var img_url=$('#upload_geturl2').val();
					if(img_url==''){
						layer.alert('请上传微信收款码！');return false;
					}
					$.ajax({
						type: 'POST',
						url: "{:url('Paytype/doawechat')}",
						dataType: "json",
						data: {selfqqname:name,selfqq:user,upload_geturl:img_url},
						success:function(re){
							var obj=re;
							if(obj.s==1){
								layer.msg(obj.msg,{shade:0.6,time:1000,end:function(){
										window.location.href=window.location.href;
									}});
							}else{
								layer.alert(obj.msg,{shade:0.2});return false;
							}
						},
						error:function(){
							layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
						}
					});
				}else{
					layer.alert(responsestr,{shade:0.2});
				}
			},
			error:function(){
				layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
			}
		});
	}
	function check_repwd_bank(){
		var name= $('input[name=realname]').val();
		var user= $('#banktypename').val();
		var files = $('input[name=bankname]').val();
		var img_url=$('input[name=bankcard]').val();
		var repwd  = $('input[name=pwd3]').val();
		if(name==''){
			layer.alert('请输入开户名！');return false;
		}
		var nameReg = /^[\u4E00-\u9FA5]{2,4}$/;
		if(!nameReg.test(name)){
			layer.alert('开户姓名格式错误，请检查！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
		}
		if(user==''){
			layer.alert('请选择开户行！');return false;
		}
		if(files==''){
			layer.alert('请填写开户支行！');return false;
		}
		if(repwd==''){
			layer.alert('请填写交易密码！');return false;
		}
		var cardcodepartten = /^(\d{16}|\d{17}|\d{18}|\d{19})$/;
		if(!cardcodepartten.test(img_url)){
			layer.alert('银行卡号格式错误，请检查！',{icon: 2,shade:0.8,title:"错误提示:"});return false;
		}
		if(img_url==''){
			layer.alert('请填写银行卡号！');return false;
		}
		/*ajax检测交易密码*/
		$.ajax({
			type: 'POST',
			url: "{:url('Paytype/check_repwd')}",
			dataType: "html",
			data: "code="+repwd,
			success:function(responsestr){
				if(responsestr==1){
					$.ajax({
						type: 'POST',
						url: "{:url('Paytype/docard')}",
						dataType: "json",
						data: {realname:name,banktypename:user,bankname:files,bankcard:img_url},
						success:function(re){
							var obj=re;
							if(obj.s==1){
								layer.msg(obj.msg,{shade:0.6,time:1000,end:function(){
										window.location.href=window.location.href;
									}});
							}else{
								layer.alert(obj.msg,{shade:0.2});return false;
							}
						},
						error:function(){
							layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
						}
					});
				}else{
					layer.alert(responsestr,{shade:0.2});
				}
			},
			error:function(){
				layer.alert('系统繁忙，请稍后再试！',{shade:0.2});
			}
		});
	}
</script>
</html>
